﻿//Author:Michal Sporna
//License: https://operationsneakpeek.codeplex.com/license

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace World
{
    public static class MapScanner
    {
        #region properties
        //public static List<Node> AllNodes { get; set; }
        public static bool IsShown;
        public static bool ShowContextMenu;
        public static Rectangle ContextMenuPosition;
        public static Node SelectedNode;
        #endregion

        #region PRIVATE
        private static bool _TexturesFoundInDraw;
        private static Texture2D _ScannerNodePhase2Texture;
        private static Texture2D _UNSelectedScannerNodeTexture;
        private static Texture2D _DisabledNodeTexture;
        private static Texture2D _SelectedScannerNodeTexture;
        private static Texture2D _GreenMarkerTexture;
        private static Texture2D _OrangeMarkerTexture;
        private static Texture2D _RedMarkerTexture;
        private static Texture2D _AvatarNodeTexture;
        #endregion

        #region METHODS

        /// <summary>
        /// Player taps on a node
        /// while the map is shown
        /// to add marker
        /// </summary>
        /// <param name="tapPos"></param>
        public static bool MarkNode(int[] tapPos)
        {
            try
            {
                if (IsShown && !ShowContextMenu) //if context menu shown, the only way to close it is to hit Cancel Button
                {
                    for(int i=0;i<WorldManager.Nodes.Count;i++)
                    {
                        //only walkable nodes can be marked
                        if (WorldManager.Nodes[i].IsWalkable)
                        {
                            if ((tapPos[0] > WorldManager.Nodes[i].Rectangle.X && tapPos[0] < WorldManager.Nodes[i].Rectangle.X + WorldManager.Nodes[i].Rectangle.Width) && (tapPos[1] > WorldManager.Nodes[i].Rectangle.Y && tapPos[1] < WorldManager.Nodes[i].Rectangle.Y + WorldManager.Nodes[i].Rectangle.Height))
                            {
                                //this is the node that user tapped on
                                MapScanner.SelectedNode = WorldManager.Nodes[i];
                                MapScanner.ShowContextMenu = true;
                                MapScanner.ContextMenuPosition = new Rectangle(WorldManager.Nodes[i].Rectangle.X + World.WorldManager.WorldConfig.NodeWidth, WorldManager.Nodes[i].Rectangle.Y, WorldManager.WorldConfig.ScannerMapContextMenuWidth, WorldManager.WorldConfig.ScannerMapContextMenuHeight);

                                //draw context menu [frist check if context menu fits the screen)
                                #region validate context menu position

                                if ((ContextMenuPosition.Y + ContextMenuPosition.Height > Util.Cache.GraphicsDevice.Viewport.Height) && (ContextMenuPosition.X + ContextMenuPosition.Width > Util.Cache.GraphicsDevice.Viewport.Width))
                                {
                                    //if context menu is too big to fit on the boundries (right and down), then draw on the left side
                                    ContextMenuPosition = new Rectangle(ContextMenuPosition.X - ContextMenuPosition.Width-WorldManager.WorldConfig.NodeWidth, Util.Cache.GraphicsDevice.Viewport.Height - WorldManager.WorldConfig.ScannerMapContextMenuHeight, ContextMenuPosition.Width, ContextMenuPosition.Height);

                                }
                                 else if (ContextMenuPosition.Y + ContextMenuPosition.Height > Util.Cache.GraphicsDevice.Viewport.Height)
                                {
                                    //context menu is out of screen, modify rectangle so it fits the screen (context menu goes up instead of down
                                    ContextMenuPosition = new Rectangle(ContextMenuPosition.X, Util.Cache.GraphicsDevice.Viewport.Height - WorldManager.WorldConfig.ScannerMapContextMenuHeight, ContextMenuPosition.Width, ContextMenuPosition.Height);
                                }
                                else if (ContextMenuPosition.X + ContextMenuPosition.Width > Util.Cache.GraphicsDevice.Viewport.Width)
                                {
                                    //draw context menu on the left instead of right
                                    ContextMenuPosition = new Rectangle(ContextMenuPosition.X - ContextMenuPosition.Width, SelectedNode.Rectangle.Y, ContextMenuPosition.Width, ContextMenuPosition.Height);
                                }
                                
                                #endregion

                                WorldManager.Nodes[i].MarkedInMap = true;

                                return true;
                            }
                        }
                    }

                }

                return false;
            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return false;
            }
        }

        /// <summary>
        /// show scanner map
        /// after it's been selected from inventory
        /// </summary>
        public static void ShowScannerMap()
        {
            try
            {
                if (!IsShown)
                {
                    //AllNodes = PathFinding.InitNodesWithReturn();

                    if (WorldManager.Nodes != null)
                    {
                        #region mark all already processed nodes (based on list from the cache

                        if (Util.Cache.ProcessedNodes != null)
                        {
                            for(int i=0;i<WorldManager.Nodes.Count;i++)
                            {
                                foreach (Classes.ScannerNode sn in Util.Cache.ProcessedNodes)
                                {
                                    //RESET pROCEssed field
                                    WorldManager.Nodes[i].Processed = false;

                                    if (sn.Rectangle.X == WorldManager.Nodes[i].Rectangle.X && sn.Rectangle.Y == WorldManager.Nodes[i].Rectangle.Y && (sn.MapCellID==Levels.LevelManager.CurrentMap.CurrentMapCell.ID))
                                    {
                                        WorldManager.Nodes[i].Processed = true;
                                        break; //go to the next node from all nodes
                                    }
                                    
                                }
                            }
                        }

                        #endregion

                        //turn on the pause
                        World.WorldManager.PauseON = true;
                        IsShown = true;
                    }

                }


            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }

        }

        /// <summary>
        /// close scanning map
        /// </summary>
        public static void CloseScannerMap()
        {
            try
            {
                if (IsShown && !ShowContextMenu)
                {
                    //AllNodes.Clear();
                    //AllNodes = null;
                    ContextMenuPosition = new Microsoft.Xna.Framework.Rectangle(-1, -1, -1, -1);
                    SelectedNode = null;


                    //for (int i = 0; i < WorldManager.Nodes.Count; i++)
                    //{
                    //    WorldManager.Nodes[i].MarkedInMap = false;
                    //    WorldManager.Nodes[i].Processed = false;
                    //}

                    IsShown = false;

                    //save markers
                    World.StorageManager.SaveWorldInfo();
                }
            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }

        /// <summary>
        /// Add marker
        /// </summary>
        public static void AddMarker(Classes.Marker marker)
        {
            try
            {
                if (Levels.LevelManager.CurrentMap.CurrentMapCell.MarkersToDraw == null)
                {
                    //create list of markers to draw in current map cell
                    Levels.LevelManager.CurrentMap.CurrentMapCell.MarkersToDraw = new List<Classes.Marker>();
                }


                //add marker
                Levels.LevelManager.CurrentMap.CurrentMapCell.MarkersToDraw.Add(marker);

                //remove 1 from markers count
                ScannerManager.TakeAwayMarker(marker.Type, 1);




            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }

        /// <summary>
        /// Remove marker
        /// </summary>
        public static void RemoveMarker(Vector2 parentNode)
        {
            try
            {
                if (Levels.LevelManager.CurrentMap.CurrentMapCell.MarkersToDraw != null)
                {
                    foreach (Classes.Marker m in Levels.LevelManager.CurrentMap.CurrentMapCell.MarkersToDraw)
                    {
                        if (m.ParentNodePos[0] == parentNode.X && m.ParentNodePos[1] == parentNode.Y)
                        {
                            Levels.LevelManager.CurrentMap.CurrentMapCell.MarkersToDraw.Remove(m);


                            //remove 1 from markers count
                            ScannerManager.AddMarker(m.Type, 1);


                            return;
                        }
                    }
                }


            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }



        /// <summary>
        /// context menu item clicked
        /// so process markers
        /// </summary>
        /// <param name="tapPos"></param>
        public static void ContextMenuItemClicked(int[] tapPos)
        {


            try
            {
                if (IsShown && ShowContextMenu)
                {
                    //declare
                    Util.Helpers.PublicEnums.MarkerType markerType = Util.Helpers.PublicEnums.MarkerType.None;
                    Util.Helpers.PublicEnums.MarkerType existingMarkerType = Util.Helpers.PublicEnums.MarkerType.None;

                    #region green marker chosen

                    if ((tapPos[0] > ContextMenuPosition.X && tapPos[0] < ContextMenuPosition.X + WorldManager.WorldConfig.scannerMapContextMenuButtonWidth) && (tapPos[1] > ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight) && tapPos[1] < ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 2)))
                    {
                        markerType = Util.Helpers.PublicEnums.MarkerType.Green;
                    }

                    #endregion

                    #region orange marker chosen

                    if ((tapPos[0] > ContextMenuPosition.X && tapPos[0] < ContextMenuPosition.X + WorldManager.WorldConfig.scannerMapContextMenuButtonWidth) && (tapPos[1] > ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 2) && tapPos[1] < ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 3)))
                    {
                        markerType = Util.Helpers.PublicEnums.MarkerType.Orange;
                    }

                    #endregion

                    #region red marker chosen

                    if ((tapPos[0] > ContextMenuPosition.X && tapPos[0] < ContextMenuPosition.X + WorldManager.WorldConfig.scannerMapContextMenuButtonWidth) && (tapPos[1] > ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 3) && tapPos[1] < ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 4)))
                    {
                        markerType = Util.Helpers.PublicEnums.MarkerType.Red;
                    }

                    #endregion

                    #region cancel button

                    if ((tapPos[0] > ContextMenuPosition.X && tapPos[0] < ContextMenuPosition.X + WorldManager.WorldConfig.scannerMapContextMenuButtonWidth) && (tapPos[1] > ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 4) + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight / 2) && tapPos[1] < ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 4) + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight / 2) + WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight))
                    {
                        ShowContextMenu = false;
                        SelectedNode.MarkedInMap = false;
                        return;
                    }


                    #endregion

                    #region exit button

                    if ((tapPos[0] > ContextMenuPosition.X && tapPos[0] < ContextMenuPosition.X + WorldManager.WorldConfig.scannerMapContextMenuButtonWidth) && (tapPos[1] > ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 5) + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight / 2) && tapPos[1] < ContextMenuPosition.Bottom))
                    {
                        ShowContextMenu = false;
                        SelectedNode.MarkedInMap = false;
                        CloseScannerMap();
                        return;
                    }


                    #endregion


                    //now if marker chosen then process it
                    if (markerType != Util.Helpers.PublicEnums.MarkerType.None)
                    {
                        existingMarkerType = SelectedNode.DoesHaveMarker();

                        //if selected node has already a marker, process it differently
                        if (existingMarkerType != Util.Helpers.PublicEnums.MarkerType.None)
                        {
                            //if marker of selected ndoe is the same as chosen marker
                            //then remove marker from the node
                            if (existingMarkerType == markerType)
                            {
                                //remove:
                                RemoveMarker(new Vector2(SelectedNode.Rectangle.X, SelectedNode.Rectangle.Y));


                            }
                            else
                            {
                                //if marker of selected node is different from selected marker
                                //then change them
                                RemoveMarker(new Vector2(SelectedNode.Rectangle.X, SelectedNode.Rectangle.Y));
                                //add new marker
                                AddMarker(new Classes.Marker(markerType, new int[]{SelectedNode.Rectangle.X, SelectedNode.Rectangle.Y}, new int[]{SelectedNode.Rectangle.X, SelectedNode.Rectangle.Y}));
                            }


                        }
                        else
                        {
                            //just add marker to the node
                            //add new marker
                            AddMarker(new Classes.Marker(markerType, new int[] { SelectedNode.Rectangle.X, SelectedNode.Rectangle.Y }, new int[] { SelectedNode.Rectangle.X, SelectedNode.Rectangle.Y }));


                        }

                        //close context menu
                        ShowContextMenu = false;
                        SelectedNode.MarkedInMap = false;
                        return;

                    }

                }


            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }


        #region DRAWING

        /// <summary>
        /// Draw map nodes
        /// </summary>
        public static void DrawMapNodes()
        {
            //declare
            Util.Helpers.PublicEnums.MarkerType markerType = Util.Helpers.PublicEnums.MarkerType.None;

            try
            {
                if (MapScanner.IsShown)
                {

                    if (!_TexturesFoundInDraw)
                    {
                        //first get all of the textures once
                        _ScannerNodePhase2Texture = Util.Cache.GetTexture("ScannerNodePhase2").Text2D;
                        _UNSelectedScannerNodeTexture = Util.Cache.GetTexture("UNSelectedScannerNode").Text2D;
                        _DisabledNodeTexture = Util.Cache.GetTexture("DisabledNode").Text2D;
                        _SelectedScannerNodeTexture = Util.Cache.GetTexture("SelectedScannerNode").Text2D;
                        _GreenMarkerTexture = Util.Cache.GetTexture("GreenMarker").Text2D;
                        _OrangeMarkerTexture = Util.Cache.GetTexture("OrangeMarker").Text2D;
                        _RedMarkerTexture = Util.Cache.GetTexture("RedMarker").Text2D;
                        _AvatarNodeTexture = Util.Cache.GetTexture("AvatarNode").Text2D;

                        _TexturesFoundInDraw = true;
                    }
                    
                    //loop thru all nodes
                    for(int i=0;i<WorldManager.Nodes.Count;i++)
                    {
                        //check if this node contains avatar
                        if (!PathFinding.IsThisNodeAvatars(WorldManager.Nodes[i]))
                        {
                            //if no avatar node then draw if processed, if walkable etc.
                            if (WorldManager.Nodes[i].Processed)
                            {
                                Util.Cache.Draw(_ScannerNodePhase2Texture, WorldManager.Nodes[i].Rectangle, Color.White);
                            }
                            else
                            {
                                if (WorldManager.Nodes[i].IsWalkable)
                                {
                                    //draw not processed
                                    Util.Cache.Draw(_UNSelectedScannerNodeTexture, WorldManager.Nodes[i].Rectangle, Color.White);
                                }
                                else
                                {
                                    //draw processed
                                    Util.Cache.Draw(_DisabledNodeTexture, WorldManager.Nodes[i].Rectangle, Color.White);
                                }

                            }
                        }
                        else
                        {
                            //if avatar, draw it as avatar node so player knows where he is
                            Util.Cache.Draw(_AvatarNodeTexture, WorldManager.Nodes[i].Rectangle, Color.White);
                        }



                        //if player marked node while in map
                        if (WorldManager.Nodes[i].MarkedInMap)
                        {
                            Util.Cache.Draw(_SelectedScannerNodeTexture, WorldManager.Nodes[i].Rectangle, Color.White);
                        }

                        //draw marker
                        markerType = WorldManager.Nodes[i].DoesHaveMarker();

                        if (markerType != Util.Helpers.PublicEnums.MarkerType.None)
                        {
                            switch (markerType)
                            {
                                case Util.Helpers.PublicEnums.MarkerType.Green:
                                    {
                                        Util.Cache.Draw(_GreenMarkerTexture, new Rectangle(WorldManager.Nodes[i].Rectangle.X, WorldManager.Nodes[i].Rectangle.Y, WorldManager.WorldConfig.MarkerWidth, WorldManager.WorldConfig.MarkerHeight), Color.White);

                                        break;
                                    }
                                case Util.Helpers.PublicEnums.MarkerType.Orange:
                                    {
                                        Util.Cache.Draw(_OrangeMarkerTexture, new Rectangle(WorldManager.Nodes[i].Rectangle.X, WorldManager.Nodes[i].Rectangle.Y, WorldManager.WorldConfig.MarkerWidth, WorldManager.WorldConfig.MarkerHeight), Color.White);
                                        break;
                                    }
                                case Util.Helpers.PublicEnums.MarkerType.Red:
                                    {
                                        Util.Cache.Draw(_RedMarkerTexture, new Rectangle(WorldManager.Nodes[i].Rectangle.X, WorldManager.Nodes[i].Rectangle.Y, WorldManager.WorldConfig.MarkerWidth, WorldManager.WorldConfig.MarkerHeight), Color.White);
                                        break;
                                    }
                            }


                        }

                    } // /foreach


                }


            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }

        /// <summary>
        /// draw context menu
        /// </summary>
        public static void DrawContextMenu()
        {
            try
            {
                if (IsShown && ShowContextMenu)
                {
                    if (SelectedNode != null)
                    {
                        

                        //draw context menu
                        Util.Cache.Draw(Util.Cache.GetTexture("SkyBackground").Text2D, ContextMenuPosition, Color.White);
                        //draw marker counters
                        #region marker counters

                        #region green marker count
                        //green
                        Util.Cache.Draw(Util.Cache.GetTexture("GreenMarker").Text2D, new Rectangle(ContextMenuPosition.X+5, ContextMenuPosition.Y+5, WorldManager.WorldConfig.NodeWidth/2,WorldManager.WorldConfig.NodeHeight/2), Color.White);
                        //green marker count
                        Util.Cache.DrawString(Util.Cache.GetFont("small").FontFace, WorldManager.GreenMarkerCount.ToString(), new Vector2(ContextMenuPosition.X + (WorldManager.WorldConfig.NodeWidth / 2)+5, ContextMenuPosition.Y + WorldManager.WorldConfig.NodeHeight / 2), 15, Color.Black);
                        #endregion

                        #region orange marker count
                        //orange
                        Util.Cache.Draw(Util.Cache.GetTexture("OrangeMarker").Text2D, new Rectangle(ContextMenuPosition.X+(2*WorldManager.WorldConfig.NodeWidth)+5, ContextMenuPosition.Y+5, WorldManager.WorldConfig.NodeWidth / 2, WorldManager.WorldConfig.NodeHeight / 2), Color.White);
                        //orange marker count
                        Util.Cache.DrawString(Util.Cache.GetFont("small").FontFace, WorldManager.OrangeMarkerCount.ToString(), new Vector2(ContextMenuPosition.X + (2 * WorldManager.WorldConfig.NodeWidth) + (WorldManager.WorldConfig.NodeWidth / 2)+5, ContextMenuPosition.Y + WorldManager.WorldConfig.NodeHeight / 2), 15, Color.Black);
                        #endregion

                        #region red marker count
                        //red
                        Util.Cache.Draw(Util.Cache.GetTexture("RedMarker").Text2D, new Rectangle(ContextMenuPosition.X + (4 * WorldManager.WorldConfig.NodeWidth)+5, ContextMenuPosition.Y+5, WorldManager.WorldConfig.NodeWidth / 2, WorldManager.WorldConfig.NodeHeight / 2), Color.White);
                        //red marker count
                        Util.Cache.DrawString(Util.Cache.GetFont("small").FontFace, WorldManager.RedMarkerCount.ToString(), new Vector2(ContextMenuPosition.X + (4 * WorldManager.WorldConfig.NodeWidth) + (WorldManager.WorldConfig.NodeWidth / 2)+5, ContextMenuPosition.Y + WorldManager.WorldConfig.NodeHeight / 2), 15, Color.Black);
                        #endregion

                        #endregion

                        //draw green marker button
                        Util.Cache.Draw(Util.Cache.GetTexture("GreenMarkerButton").Text2D, new Rectangle(ContextMenuPosition.X, ContextMenuPosition.Y + WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight, WorldManager.WorldConfig.scannerMapContextMenuButtonWidth, WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight), Color.White);
                        Util.Cache.DrawString(Util.Cache.GetFont("HUDScore").FontFace, "Green Marker", new Vector2(ContextMenuPosition.X + 5, ContextMenuPosition.Y + WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight + 5), 8, Color.Black);

                        //draw orange marker button
                        Util.Cache.Draw(Util.Cache.GetTexture("OrangeMarkerButton").Text2D, new Rectangle(ContextMenuPosition.X, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight*2), WorldManager.WorldConfig.scannerMapContextMenuButtonWidth, WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight), Color.White);
                        Util.Cache.DrawString(Util.Cache.GetFont("HUDScore").FontFace, "Orange Marker", new Vector2(ContextMenuPosition.X + 5, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 2) + 5), 8, Color.Black);
                        //draw red marker button
                        Util.Cache.Draw(Util.Cache.GetTexture("RedMarkerButton").Text2D, new Rectangle(ContextMenuPosition.X, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight*3), WorldManager.WorldConfig.scannerMapContextMenuButtonWidth, WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight), Color.White);
                        Util.Cache.DrawString(Util.Cache.GetFont("HUDScore").FontFace, "Red Marker", new Vector2(ContextMenuPosition.X + 5, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 3) + 5), 8, Color.Black);
                        //draw cancel button
                        Util.Cache.Draw(Util.Cache.GetTexture("ContextMenuCancelButton").Text2D, new Rectangle(ContextMenuPosition.X, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 4)+(WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight/2), WorldManager.WorldConfig.scannerMapContextMenuButtonWidth, WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight), Color.White);
                        Util.Cache.DrawString(Util.Cache.GetFont("HUDScore").FontFace, "Cancel", new Vector2(ContextMenuPosition.X + 5, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 4) + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight/2)+5), 8, Color.Black);
                        //exit button
                        Util.Cache.Draw(Util.Cache.GetTexture("ExitButton").Text2D, new Rectangle(ContextMenuPosition.X, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 5) + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight), WorldManager.WorldConfig.scannerMapContextMenuButtonWidth, WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight), Color.White);
                        Util.Cache.DrawString(Util.Cache.GetFont("HUDScore").FontFace, "Exit Map", new Vector2(ContextMenuPosition.X + 5, ContextMenuPosition.Y + (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight * 5)+ (WorldManager.WorldConfig.ScannerMapContextMenuButtonHeight)+ 5), 8, Color.Black);

                        //draw markers counter
                        //Util.Cache.Draw(Util.Cache.GetTexture("ContextMenu").Text2D, new Rectangle(SelectedNode.Rectangle.X,SelectedNode.Rectangle.Y-, Color.White);

                    }
                }


            }
            catch (Exception ex)
            {
                Util.ErrorLogging.LogError(ex);
                return;
            }
        }

        #endregion


        #endregion

    }
}
